# mongoose = require('mongoose')
# mongoose.connect('mongodb://localhost/test')
# Schema = mongoose.Schema
# ObjectId = Schema.ObjectId;
# Note = new Schema
#   name: String

# express  = require "express"
coffee  = require "coffee-script"
util    = require "util"
_       = require "../lib/underscore.js"
db      = require("mongous").Mongous
puts    = console.log # shortcut


class Project
  constructor: (title, author) ->
    @title  = title
    @author = authors
  

class Idea extends Project
  constructor: (title, author) ->
    super(title, author)

ProjectManagementSystem = {
  createIdea: (title, author ) ->
    new Idea(title, author)
}

###
db("test.notes").find {}, (r) ->
  puts e.name for e in r.documents
###
# console.log util.inspect(Note, true, null)
# ---------------------------------------
class Employee
  constructor: (id, name) ->
    @id = id
    @name = name

  makeIdea: (caption, desc, color="red") ->
    idea = new Idea
      caption: caption
      desc: desc
      color: color
      author: @name
# ---------------------------------------
allMonths = [
  "january", "february", "mars"
  "april", "may", "june", "july"
  "august", "september", "octobre"
  "novembre", "decembre"
]
# ---------------------------------------

exports.index = (req, res) ->
  sobah = new Employee 23, "Sobah"
  idea = sobah.makeIdea "WeatherMachine", "A WeatherMachine is a nice device"
  res.render "index",
    title: "Kraken: Express"
    menu: ["Home", "Browse", "Help"]
    makeitem: (x) -> "<a>#{x}</a>"

exports.ideas = (req, res) ->
  db("test.notes").find {}, (r) ->
    puts e.name for e in r.documents
    res.render "postit",
      title: "Post-it's are awesome"
      notes: note for note in r.documents
    # notes: ["Make Coffee", "Be Awesome", "Conformity ftw!"]

exports.ideasdata = (req, res) ->
  # db.ideas.find()
  res.send
    notes: ["Make Coffee", "Be awesome", "Conformity ftw!"]

exports.timeline = (req,res) ->
  db("test.events").find {quarter: 2}, (r) ->
    res.render "timeline"
      title: "The Timeline"
      months: allMonths
      projects: r.documents # array of projects

exports.batman = (req,res) ->
  res.send
    kakefjes: "Hey batman"

